//
//  GHBlurtView.m
//  Diary
//
//  Created by lanou3g on 15/10/30.
//  Copyright © 2015年 王艺拓. All rights reserved.
//

#import "GHBlurtView.h"

@implementation GHBlurtView

- (instancetype)initWithEffect:(UIVisualEffect *)effect
{
    self = [super initWithEffect:effect];
    if (self) {
        self.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
        self.alpha = 0;
        [self addViews];
    }
    return self;
}

- (void)addViews
{
    // 毛玻璃上滚动动画
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(-kScreenWidth * 0.25, -kScreenHeight * 0.25, kScreenWidth, kScreenHeight *0.8)];
    self.scrollView.backgroundColor = [UIColor clearColor];
    self.scrollView.alwaysBounceVertical = NO;
    self.scrollView.pagingEnabled = YES;
    [self addSubview:self.scrollView];
    
    //加个返回提示
    self.directionLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, kScreenWidth / 12, kScreenWidth, kScreenHeight / 20)];
    self.directionLabel.backgroundColor = [UIColor clearColor];
    self.directionLabel.font = [UIFont systemFontOfSize:18];
    self.directionLabel.text = @"点击其他部分返回";
    self.directionLabel.textColor = [UIColor whiteColor];
    self.directionLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.directionLabel];
    
    //
    //    // 标题背景
    //    self.bgImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight*0.8)];
    //    self.bgImg.backgroundColor = [UIColor yellowColor];
    //    self.bgImg.contentMode = UIViewContentModeScaleAspectFit;
    //    self.bgImg.userInteractionEnabled = YES;
    ////    self.bgImg.layer.masksToBounds = YES;
    //    [self.scrollView addSubview:self.bgImg];
    
#pragma mark - 毛玻璃上方的label
    //    // 标题
    //    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, kScreenHeight * 0.2, kScreenWidth, kScreenHeight * 0.05)];
    //    self.titleLabel.text = @"奥森公园";
    //
    //    //    titleLabel.backgroundColor = [UIColor whiteColor];
    //    self.titleLabel.textColor = [UIColor whiteColor];
    //    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    //    [self addSubview:_titleLabel];
    //
    //    // 日期
    //    self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.titleLabel.frame), kScreenWidth, kScreenHeight *  0.04)];
    //    self.dateLabel.textAlignment = NSTextAlignmentCenter;
    //    self.dateLabel.text = @"2015年14月37";
    //    //    dateLabel.backgroundColor = [UIColor whiteColor];
    //
    //    self.dateLabel.textColor = [UIColor whiteColor];
    //    [self addSubview:_dateLabel];
    //
    //    // 地址
    //    self.addressView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.dateLabel.frame) * 1.05, kScreenWidth, kScreenHeight * 0.03)];
    //    //    addressView.backgroundColor = [UIColor orangeColor];
    //    [self addSubview:_addressView];
    //
    //    // 天气图标
    //    self.weatherImgV = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth * 0.25, 0, kScreenWidth * 0.05, kScreenWidth * 0.05)];
    //    self.weatherImgV.backgroundColor = [UIColor redColor];
    //    [self.addressView addSubview:_weatherImgV];
    //
    //    // 地址图标
    //    self.addressView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.weatherImgV.frame) * 1.1, 0, kScreenWidth * 0.05, kScreenWidth * 0.05)];
    //    self.addressImgV.backgroundColor = [UIColor purpleColor];
    //    [self.addressView addSubview:_addressImgV];
    //
    //    // 地址
    //   self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.addressImgV.frame), 0, kScreenWidth * 0.4, kScreenHeight * 0.03)];
    //    self.addressLabel.text = @"北京市朝阳区 林萃路";
    //    //    adddressLabel.backgroundColor = [UIColor grayColor];
    //    self.addressLabel.textAlignment = NSTextAlignmentCenter;
    //    self.addressLabel.textColor = [UIColor whiteColor];
    //
    //    [self.addressView addSubview:_addressLabel];
    //#pragma mark - 毛玻璃下方的label
    //    self.bookImagV = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth * 0.45, kScreenHeight * 0.82, kScreenWidth * 0.1, kScreenHeight * 0.05)];
    //    self.bookImagV.backgroundColor = [UIColor brownColor];
    //    [self addSubview:_bookImagV];
    //
    //    self.bookLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth * 0.3, CGRectGetMaxY(self.bookImagV.frame) * 1.01, kScreenWidth * 0.4, kScreenHeight * 0.03)];
    //    self.bookLabel.textAlignment = NSTextAlignmentCenter;
    //    self.bookLabel.text = @"共12篇";
    //
    //    self.bookLabel.textColor = [UIColor whiteColor];
    //    //    bookLabel.backgroundColor = [UIColor magentaColor];
    //    [self addSubview:_bookLabel];
}

- (void)fitAutoFont
{
    if ([WYTDevicesTool iPhone320_DEVICES]) {
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        self.dateLabel.font = [UIFont systemFontOfSize:14];
        self.addressLabel.font = [UIFont systemFontOfSize:14];
        self.bookLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhone4_iPhone4s]) {
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        self.dateLabel.font = [UIFont systemFontOfSize:14];
        self.addressLabel.font = [UIFont systemFontOfSize:14];
        self.bookLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhone5_iPhone5s_iPhone5c]) {
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        self.dateLabel.font = [UIFont systemFontOfSize:14];
        self.addressLabel.font = [UIFont systemFontOfSize:14];
        self.bookLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhone6_iPhone6s]) {
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        self.dateLabel.font = [UIFont systemFontOfSize:14];
        self.addressLabel.font = [UIFont systemFontOfSize:14];
        self.bookLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhone6Plus_iPhone6sPlus]) {
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        self.dateLabel.font = [UIFont systemFontOfSize:14];
        self.addressLabel.font = [UIFont systemFontOfSize:14];
        self.bookLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhoneNONE_PLUS]) {
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        self.dateLabel.font = [UIFont systemFontOfSize:14];
        self.addressLabel.font = [UIFont systemFontOfSize:14];
        self.bookLabel.font = [UIFont systemFontOfSize:13];
    }
}

@end
